#!/usr/bin/env python
# coding: utf-8
# @Time    : 2021/11/17 14:01
# @Author  : YD
# @Email   : dinhe_1985@126.com 
# @File    : logging_conf.py
# @Software: PyCharm
# @Blog    : www.noteshare.cn
from conf.api_conf import LOGFILE_PATH

LOGGING_CONFIG = {
    'version': 1,
    'formatters': {
        'standard': {
            'format': '[%(asctime)s] - [%(levelname)s] - [%(message)s]',
            'datefmt': '%Y-%m-%d %H:%M:%S'
        }
    },
    'handlers': {
        'file': {
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'formatter': 'standard',
            'filename': '{}'.format(LOGFILE_PATH),
            'when': 'MIDNIGHT',
            'interval': 1,
            'backupCount': 30,
            'level': 'DEBUG',
            'encoding': 'utf-8',
        },
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'standard',
            'level': 'DEBUG'
        },
        'root_file': {
            'class': 'logging.handlers.TimedRotatingFileHandler',
            'formatter': 'standard',
            'filename': '{}'.format(LOGFILE_PATH),
            'when': 'MIDNIGHT',
            'interval': 1,
            'backupCount': 30,
            'level': 'DEBUG',
            'encoding': 'utf-8',
        },
    },
    'loggers': {
        'file_logger': {
            'handlers': ['file'],
            'level': 'WARNING',
            "propagate": False,
        },
        'file_console_logger': {
            'handlers': ['file', 'console'],
            'level': 'WARNING',
            "propagate": False,
        }
    },
    'root': {
        'handlers': ['root_file'],
        'level': 'DEBUG'
    },
    "disable_existing_loggers": True,
}
